﻿
using Architecture.Api.Application.Commands.SlaughterCommand;
using Architecture.Api.Application.Commands.SlaughterCorporationCommand;
using Architecture.Domain.TraceabilityManage;
using Architecture.Domian.DTO;
using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;


namespace Architecture.Api.Controllers
{
    /// <summary>
    /// 屠宰API接口
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    [Authorize]
    public class SlaughterController : ControllerBase
    {
        private readonly IMediator _mediator;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="mediator"></param>
        public SlaughterController(IMediator mediator)
        {
            _mediator = mediator;
        }

        /// <summary>
        /// 添加屠宰信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> AddSlaughter(SlaughterCreateCommand command)
        {
            return await _mediator.Send(command);
        }

        /// <summary>
        /// 根据生产批次号查询屠宰信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Slaughter> GetSlaughterInfo([FromQuery] SlaughterQueryCommand command)
        {
            return await _mediator.Send(command);
        }

        /// <summary>
        /// 修改屠宰信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<int> UpdateSlaughter(SlaughterUpdateCommand command)
        {
            return await _mediator.Send(command);
        }

        /// <summary>
        /// 批量操作屠宰相关资质照片
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> BatchSlaughterPicList(SlaughterBatchSlaughterPicCommand command)
        {
            return await _mediator.Send(command);
        }

        /// <summary>
        /// 显示屠宰相关资质照片
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<PictureDTO>> GetSlaughterPicture([FromQuery] SlaughterQuerySlaughterPictureCommand command)
        {
            return await _mediator.Send(command);
        }


        /// <summary>
        /// 显示企业照片
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<PictureDTO>> GetCorporationPicture([FromQuery] SlaughterCorporationQuerySlaughterPicCommand command)
        {
            return await _mediator.Send(command);
        }

        /// <summary>
        /// 批量操作企业照片
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> BatchCorporationPicList(SlaughterCorporationBatchSlaughterPicCommand command)
        {
            return await _mediator.Send(command);
        }

        /// <summary>
        /// 添加公司
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> AddCorporation(SlaughterCorporationCreateCommand command)
        {
            return await _mediator.Send(command);
        }

        /// <summary>
        /// 显示公司
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Corporation> GetCorporationInfo([FromQuery] SlaughterCorporationQueryInfoCommand command)
        {
            return await _mediator.Send(command);
        }

        /// <summary>
        /// 修改公司
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<int> UpdateCorporation(SlaughterCorporationUpdateCommand command)
        {
            return await _mediator.Send(command);
        }
    }
}
